Crate octseq

source ·
Expand description

Variable length octet sequences.

This crate provides a set of basic traits that allow defining types that are generic over a variable length sequence of octets (or, vulgo: bytes).

There are two groups of traits: those that represent behavior of imutable octets sequences are collected in the module octets and those for building such sequences are in builder. Most traits from these modules are also re-exported at the crate root for convenience.

These traits are implemented for a number of types. Apart from [u8], the implementations are opt-in via features. These are:

  • std for Vec<u8>, Cow<[u8]>, and Arc<[u8]>,
  • bytes for the Bytes and BytesMut types from the bytes crate,
  • heapless for the Vec<u8, N> type from the heapless crate, and
  • smallvec for a smallvec for item type u8 from the smallvec crate.

A number of additional modules exist that provide a few helpful things:

  • The array module provides an octets builder backed by an octets array.
  • The str module provides both imutable and buildable string types that are generic over the octets sequence they wrap.
  • The serde module, which needs to be enabled via the serde feature, provides traits and functions to more efficiently serialize octets sequences.

Re-exports

Modules

  • A fixed-capacity octets sequence.
  • Octets Builders
  • Octets Sequences
  • Reading data from an octet sequence.
  • Serde support.
  • Strings atop octet sequences.